package com.verifone.tony.databasetest;

//--------------------- dbflow --------------------------

import com.raizlabs.android.dbflow.annotation.Database;
import com.raizlabs.android.dbflow.annotation.Migration;
import com.raizlabs.android.dbflow.sql.SQLiteType;
import com.raizlabs.android.dbflow.sql.migration.AlterTableMigration;

/**
 * Created by chong.z on 2017/11/14.
 */

@Database(name = MyDatabase.NAME, version = MyDatabase.VERSION)
public class MyDatabase {
    public static final String NAME = "MyDataBase";
    //change model [1]
    public static final int VERSION = 3;

    /**
     * 数据库的修改：
     * 1、PatientSession 表结构的变化
     * 2、增加表字段，考虑到版本兼容性，老版本不建议删除字段
     */
    @Migration(version = VERSION, database = MyDatabase.class)
    public static class Migration2UserData extends AlterTableMigration<DBFlowModel> {

        public Migration2UserData(Class<DBFlowModel> table) {
            super(table);
        }

        //change model [2]
        @Override
        public void onPreMigrate() {
            addColumn(SQLiteType.TEXT, "email");
        }
    }
}
